﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace DataAccess
{
   public class LienHe_Info
    {
        public int ID { get; set; }
        public string HoVaTen { get; set; }
        public string Email { get; set; }
        public string SoDienThoai { get; set; }
        public string NoiDung { get; set; }
        public bool TrangThai { get; set; }

        public static List<LienHe_Info> LienHes_ChonTatCa()
        {
            return CBO.FillCollection<LienHe_Info>(DataProvider.Instance.ExecuteReader("sp_LienHes_ChonTatCa"));
        }
        public static LienHe_Info LienHe_Chon(int ID)
        {
            return CBO.FillObject<LienHe_Info>(DataProvider.Instance.ExecuteReader("sp_LienHe_Chon", ID));
        }
        public static bool LienHe_Them(string HoVaTen, string Email, string SoDienThoai, string NoiDung, bool trangthai)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("sp_LienHe_Them", HoVaTen, Email, SoDienThoai, NoiDung, trangthai);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool LienHe_CapNhat(int ID, bool trangthai)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("sp_LienHe_CapNhat", ID, !trangthai);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }


        public static bool LienHe_Xoa(int ID)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("sp_LienHe_Xoa", ID);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static List<LienHe_Info> LienHes_HoatDong(bool trangthai)
        {
            return CBO.FillCollection<LienHe_Info>(DataProvider.Instance.ExecuteReader("sp_LienHes_HoatDong", trangthai));
        }
    }
}
